package com.mer.statistic.service;

import com.mer.statistic.entity.Member;
import com.mer.statistic.mapper.MemberMapper;
import com.mer.statistic.utils.Result;
import com.mer.statistic.vo.MemberVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @program: iiphase-project-master
 * @description:
 * @author: 薛宁宁
 * @create: 2021-10-18 22:05
 **/
@Service
public class MemberImpl implements MemberService {
    @Resource
    private MemberMapper memberMapper;
    @Override
    public Result queryByMemberType(Member member) {
        List<MemberVo> maps = memberMapper.queryByMemberType(member);
        List<Map> collect = maps.stream().map(item -> {
            Map<String, Object> map = new HashMap<>();
            map.put("name", item.getName() ? "会员" : "讲师");
            map.put("value", item.getValue());
            return map;
        }).collect(Collectors.toList());
        return new Result(2000,"查询成功",collect);
    }

}
